<template>
  <div class="app-container">
    <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
      <el-form-item label="品牌名称" prop="brand_name">
        <el-input
          v-model="queryParams.brand_name"
          placeholder="品牌名称"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list" style="width: 100%;" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center" />
      <!--      <el-table-column label="ID" align="center" prop="id" />-->
      <el-table-column label="新生订单ID" align="center" prop="orderId" />
      <el-table-column label="订单号" align="center" prop="merOrderId" />
      <el-table-column label="商户显示名称" align="center" prop="displayName" />
      <el-table-column label="商户用户姓名" align="center" prop="customerName" :show-overflow-tooltip="true" />
      <el-table-column label="状态" align="center" prop="item_status" />
      <el-table-column label="订单金额" align="center" prop="orderAmount" />
      <el-table-column label="详情" align="center" width="50">
        <template v-slot="scope">
          <span style="color: #20a0ff;cursor:pointer" @click="see(scope.row)">查看</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
        <template v-slot="scope">
          <el-button
            :disabled="scope.row.push_inventory === 800 || scope.row.push_inventory === 899"
            size="mini"
            type="primary"
            @click="declare(scope.row,'推送')"
          >推送</el-button>
          <!-- @click="select(scope.row)" -->
          <!-- :disabled="scope.row.push_inventory === 0 ? true : false" -->
          <el-button
            size="mini"
            type="success"
          >同步回执</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit" @pagination="getList" />
    <!-- 查看详情 -->
    <Detail :show.sync="show" :form="form" />
    <!-- 推送 -->
    <push :show.sync="tshow" :form="tform" />
  </div>

</template>
<style>
.el-input__inner {
  width: 90%;
}
.el-input__suffix {
  right: 10%;
}
</style>
<script>
import { getXspayList } from '@/api/order'
import Detail from './Detail.vue'
import push from './push.vue'
export default {
  name: 'Index',
  components: {
    Detail,
    push
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 10
      },
      show: false,
      form: {},
      multipleSelection: [],
      tshow: false,
      tform: {}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    declare(row, type) {
      this.tshow = true
      this.tform = row
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    see(row) {
      this.show = true
      this.form = row
    },
    /** 查询清单列表 */
    getList() {
      this.loading = true
      getXspayList(this.queryParams).then(response => {
        console.log(response)
        this.list = response.data
        this.list.forEach(item => {
          if (item.status == 0) {
            item.item_status = '未付款'
          } else if (item.status == 1) {
            item.item_status = '已付款'
          } else {
            item.item_status = '失败'
          }
        })
        this.total = response.count
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        page: 1,
        limit: 10,
        brand_name: undefined
      }
      this.handleQuery()
    }
  }
}
</script>

